package com.yang.web.dao;

import com.yang.common.entity.Permission;
import com.yang.common.entity.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

@Mapper
@Repository
public interface PermissionDao {
    @Select("select * from permission where pid is null")
    Permission queryRootPermission();

    @Select("select * from permission where pid = #{pid}")
    List<Permission> queryChildPermissions(Integer pid);

    @Select("select * from permission")
    List<Permission> queryAll();

    void insertPermission(Permission permission);

    @Select("select * from permission where id = #{id}")
    Permission queryById(Integer id);

    void updatePermission(Permission permission);

    void deletePermission(Permission permission);

    @Select("select permissionid from rolepermission where roleid = #{roleid}")
    List<Integer> queryPermissionidsByRoleid(Integer roleid);

    List<Permission> queryPermissionsByUser(User dbUser);
}
